module AuthenticatedSystem
  
  def admin?
    for role in current_user.roles
      user = :true if role.name == 'admin' && logged_in?
    end
    user
    
  end
  
  def power_user?
    logged_in? &&  current_user.role.name == 'power_user'
  end
  
  def logged_in?
    current_user != :false
  end
  
  def login_from_session
    User.find session[:user_id]
  end
  
  def login_from_cookie
  end
  
  def current_user
    @current_user ||= (login_from_session || login_from_cookie || :false)
  end
  
  
  
end